//
//  CloudTagLabelVC.swift
//  SwiftLearning
//
//  Created by 黄龙 on 2024/1/25.
//

import UIKit

class CloudTagLabelVC: BasicNavibarVC {
    var mTagView:TQQCloudTagView?
    var mQvodView:TQQKuaiboTagView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.rightBar.title = "Fresh"
    }
    
    override func initView(){
        let titles = ["当幸福来敲门", "海滩", "如此的夜晚", "大进军", "险地", "姻缘订三生", "死亡城", "苦海孤雏", "老人与海", "烽火异乡情", "父亲离家时", "无情大地补情天", "以眼还眼", "锦绣人生", "修女传", "第十三号", "末代启示录", "西北前线", "西北区骑警", "黄金广场大劫案", "畸恋山庄", "守夜", "我们爱黑夜", "恐怖夜校", "夏尔洛结婚", "特别的一夜", "下一站格林威治村", "升职记", "恶夜之吻", "木匠兄妹故事"]
        mTagView = TQQCloudTagView(frame: CGRect(x: 0, y: 0, width: screen_W, height: 200), titleArr:titles , colorArr: [.systemRed,.cyan,.systemBlue,.systemPurple,.systemBrown,.label,.systemOrange,.systemTeal,.systemPink,.systemIndigo,.magenta], fontArr: [.systemFont(ofSize: 11),.systemFont(ofSize: 13),.systemFont(ofSize: 16),.systemFont(ofSize: 20)],rowHeight: 35.0)
        if let tagView = mTagView{
            workView.addSubview(tagView)
            tagView.backgroundColor = .secondarySystemBackground
            tagView.tapBlock = { [weak self](index) in
                NSLog("tapIndex:[%d]%@", index,titles[index])
                self?.title = titles[index]
                if let label = tagView.viewWithTag(index) as? UILabel{
                    let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
                    scaleAnimation.duration = 0.25;
                    scaleAnimation.fromValue = 1.0
                    scaleAnimation.toValue = 0.85
                    label.layer.add(scaleAnimation, forKey: "title.scaleXY")
                }
            }
        }
        
        mQvodView = TQQKuaiboTagView(frame: CGRect(x: 50, y: 300, width: screen_W-100, height: 300), titles: titles)
        if let qvodView = mQvodView{
            workView.addSubview(qvodView)
            qvodView.layer.borderColor = UIColor.tertiarySystemBackground.cgColor
            qvodView.layer.borderWidth = 0.5
            qvodView.fillSomeWhenShow(count: 4)
            qvodView.startQvod()
            qvodView.tapBlock = {[weak self](title) in
                self?.title = title
            }
        }
        
    }
    
    override func clickRightbarItem() {
        if let tagView = mTagView{
            tagView.initUI()
        }
        
        if let qvodView = mQvodView{
            let titles = ["西北区骑警", "黄金广场大劫案","当幸福来敲门", "畸恋山庄", "守夜", "我们爱黑夜", "恐怖夜校", "夏尔洛结婚", "特别的一夜", "下一站格林威治村", "升职记", "恶夜之吻", "海滩", "如此的夜晚", "大进军", "险地", "姻缘订三生", "死亡城", "苦海孤雏", "当幸福来敲门我却不在家操蛋了","老人与海", "烽火异乡情", "父亲离家时", "无情大地补情天", "以眼还眼", "锦绣人生", "修女传", "第十三号", "末代启示录", "西北前线","木匠兄妹故事"]
            qvodView.reloadDataAndQvod(titls: titles)
        }
    }

}
